package com.wn.pay.controller;

import com.wn.common.model.dto.pay.PayBackDTO;
import com.wn.common.result.Result;
import com.wn.pay.service.IBorrowerPayPlanService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 借款人还款计划 前端控制器
 * </p>
 *
 * @author yellow docker
 * @since 2023-08-07
 */
@RestController
@RequestMapping("/pay")
public class BorrowerPayPlanController {

    @Autowired
    private IBorrowerPayPlanService borrowerPayPlanService;

    @ApiOperation("开启还款") // 放款：接口4，开启还款
    @PostMapping("/inner/plan")
    public Result<String> payPlan(
            @RequestBody PayBackDTO payBackDTO) {
        String result = borrowerPayPlanService.payPlan(payBackDTO);
        return Result.ok(result);
    }

    @ApiOperation("用户还款")
    @GetMapping("/repay/date")
    public Result doRepay(String date) {
        borrowerPayPlanService.doRepay(date);
        return Result.ok("还款成功");
    }

}
